package com.neu.his.controller.lastVerssion;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.neu.his.core.Result;
import com.neu.his.entity.DiagRecords;
import com.neu.his.entity.DrugDisturb;
import com.neu.his.entity.NonDrugDisturb;
import com.neu.his.entity.request.lastVerssion.DiagParams;
import com.neu.his.mapper.DiagRecordMapper;
import com.neu.his.mapper.DrugDisturbMapper;
import com.neu.his.mapper.NonDrugDisturbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description: neu-his
 * <p>
 * Created by 31316 on 2020/7/19 17:53
 */
@RestController
@RequestMapping("/finishDiag")
public class FinishDiagController {
    @Autowired
    NonDrugDisturbMapper nonDrugDisturbMapper;

    @Autowired
    DrugDisturbMapper drugDisturbMapper;

    @Autowired
    DiagRecordMapper diagRecordMapper;

    @PostMapping
    public Result finishDiag(@RequestBody DiagParams diagParams) {
        Long id = new Long(diagParams.getDiagId());
        diagRecordMapper.update(null, new UpdateWrapper<DiagRecords>()
                .ne("remove_mark", 1L).eq("id", id).set("remove_mark", 1L));
        nonDrugDisturbMapper.update(null, new UpdateWrapper<NonDrugDisturb>()
                .ne("remove_mark", 1L).eq("diag_id", id).set("remove_mark", 1L));
        drugDisturbMapper.update(null, new UpdateWrapper<DrugDisturb>()
                .ne("remove_mark", 1L).eq("diag_id", id).set("remove_mark", 1L));
        return Result.success("诊毕");
    }
}
